fix(agent-context): apply default markers when config markers are blank (bash)#3736
Open
matecardoso wants to merge 1 commit into
Open
fix(agent-context): apply default markers when config markers are blank (bash)#3736matecardoso wants to merge 1 commit into
matecardoso wants to merge 1 commit into
Conversation
…nk (bash)
When the extension config omits context_markers (or sets them blank),
relying on the built-in defaults, the Bash port aborted with "malformed
config parser output" and never updated the context file, while the
Python (`or DEFAULT_*`) and PowerShell (default-initialized) ports handled
it correctly.
The config parser prints three lines (context_files JSON, marker_start,
marker_end), captured via `_raw_opts="$(...)"`. Command substitution strips
trailing newlines, so blank marker lines collapse the output to fewer than
three, tripping the `(( ${#_opts_lines[@]} < 3 ))` guard and making the
DEFAULT_START/END substitution unreachable — the exact case it was written
for.
Require only the context_files line and default the marker lines to empty
(`${_opts_lines[1]:-}` / `${_opts_lines[2]:-}`) so the existing
DEFAULT_START/END fallback fills them in. Add a parity regression test with
blank markers (it fails on the old guard and passes with the fix).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Bash agent-context updates when markers are omitted or blank, restoring parity with Python and PowerShell.
Changes:
- Accepts missing marker lines and applies built-in defaults.
- Adds regression coverage for blank markers and cross-port parity.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
extensions/agent-context/scripts/bash/update-agent-context.sh |
Handles stripped blank marker lines safely. |
tests/extensions/test_update_agent_context_python_parity.py |
Tests default-marker behavior and Bash/Python parity. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #3735.
When the extension config omits
context_markers(or sets them blank) to rely on the built-in defaults, the Bash port aborted withmalformed config parser outputand never updated the context file, while the Python (... or DEFAULT_*) and PowerShell (default-initialized) ports handled it correctly.The config parser prints three lines (context_files JSON,
marker_start,marker_end), captured via_raw_opts="$(...)". Command substitution strips trailing newlines, so blank marker lines collapse the output to fewer than three, tripping the(( ${#_opts_lines[@]} < 3 ))guard and making theDEFAULT_START/DEFAULT_ENDsubstitution below unreachable — the exact case it was written for.Fix: require only the mandatory context_files line, and default the marker lines to empty (
${_opts_lines[1]:-}/${_opts_lines[2]:-}) so the existing default-marker substitution fills them in. Single source of truth for the defaults stays in the Bash script.Testing
pytest tests/extensions/— 213 passed, 63 skipped (PowerShell parity skipped: nopwshlocally).test_python_blank_markers_use_defaults_matching_bashto the parity suite. Verified it fails on the old guard (Bash exits without updating while Python writes the section → parity mismatch) and passes with the fix.AI Disclosure
The fix and the regression test were written by Claude (Anthropic) under my direction, and I reviewed them. The bug surfaced while enabling this extension in a downstream project; an automated code review flagged the cross-platform divergence, which I traced to the command-substitution newline-stripping interacting with the 3-line guard.